package org.mikeliu.exp2.exp4;

import java.util.Arrays;
import java.util.Scanner;


abstract class Shape
{
	final static public double PI=3.14;
	public abstract double getPerimeter();
	public abstract double getArea();
	public static double sumAllArea(Shape[] s)
	{
		double sum=0;
		for(int i=0;i<s.length;i++)
		{
			sum+=s[i].getArea();
		}
		return sum;
	}
	public static double sumAllPerimeter(Shape[] s)
	{
		double sum=0;
		for(int i=0;i<s.length;i++)
		{
			sum+=s[i].getPerimeter();
		}
		return sum;
	}
	
}

class Rectangle extends Shape
{
	private int width;
	private int length;
	
	public Rectangle(int width,int lenght)
	{
		this.width=width;
		this.length=lenght;
	}
	
	public double getPerimeter()
	{
		return 2*(width+length);
	}
	
	public double getArea()
	{
		return width*length;
	}
	
	@Override
	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}
	
	
}

class Circle extends Shape
{
	private int radius;
	
	public Circle(int radius)
	{
		this.radius=radius;
	}
	
	public double getPerimeter()
	{
		return 2*PI*radius;
	}
	
	public double getArea()
	{
		return PI*radius*radius;
	}
	
	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}
	
}

public class Exp4
{
	public static void main(String[] args) 
	{
		int n;
		String type;
		
		Scanner scanner=new Scanner(System.in);
		n=scanner.nextInt();
		Shape[] shapes=new Shape[n];
		for(int i=0;i<n;i++)
		{
			scanner.nextLine();
			type=scanner.nextLine();
			if(type.equals("rect"))
			{
				int width,length;
				width=scanner.nextInt();
				length=scanner.nextInt();
				shapes[i]=new Rectangle(width, length);
			}
			else if(type.equals("cir")) 
			{
				int radius;
				radius=scanner.nextInt();
				shapes[i]=new Circle(radius);
			}
		}
		System.out.println(Shape.sumAllPerimeter(shapes));
		System.out.println(Shape.sumAllArea(shapes));
		System.out.println(Arrays.toString(shapes));
		for(int i=0;i<n;i++)
		{
			System.out.println(shapes[i].getClass()+","+shapes[i].getClass().getSuperclass());
		}
		
		scanner.close();
	}
}
